{extend name="./oscshop/admin/view/public/base.html" /}
{block name="content"}
<?php use think\Db; ?>
<div class="page-header">
		<h1>
			{$breadcrumb2}
			<small>
				<i class="ace-icon fa fa-angle-double-right"></i>
				{$crumbs}
			</small>
		</h1>
</div>
<ul class="nav nav-tabs">
	  <li class="active"><a href="#tab-order" data-toggle="tab">订单商品</a></li>
	  <li><a href="#tab-refund" data-toggle="tab">退换货申请</a></li>
</ul>

<div class="tab-content">
	<div id="tab-order" class="tab-pane active">
       <table class="table table-bordered">
          <thead>
            <tr>
              <td class="left">商品品名</td>
             
              <td class="right">数量</td>
            
              <td class="right">价格</td>         
              <td class="left">型号</td>     
              <td class="right">总计</td>
            
            </tr>
          </thead>
          <tbody>
          		{volist name="$list['order_product']" id="p"}
          			<tr>
          				<td>
          					<img src="IMG_ROOT{$p.image|resize=50,50}" />
			              	<a><?php echo $p['name']; ?></a>
			              	<?php if($option_list=Db::query('select * from '.config('database.prefix').'order_option where order_goods_id='.$p['order_goods_id'].' and order_id='.$p['order_id'])){ ?>
							<?php foreach ($option_list as $option) { ?>
			                <br />
			                &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
			                <?php } ?>
			                <?php } ?>
          				</td>
          				<td>
          					{$p.quantity}
          				</td>
          				<td>{$p.price}</td>
          				<td>{$p.model}</td>
          				<td>{$p.total}</td>
          			</tr>
          		{/volist}
          </tbody>	 
          <?php if(isset($list['total'])&&is_array($list['total'])){ ?>
	          <?php foreach ($list['total'] as $totals) { ?>
	          <tbody>
	            <tr>
	              <?php if($totals['code']=='shipping'){ ?>	
	              	<td colspan="4" class="right"><?php echo $totals['title']; ?>:</td>
	              	<td class="right">￥
	                	<?php echo $totals['value']; ?>
	                </td>
	              <?php }else{ ?>	
		              <td colspan="4" class="right"><?php echo $totals['title']; ?>:</td>
		              
		              <td class="right"><?php echo $totals['text']; ?></td>
	              <?php } ?>
	              
	              
	            </tr>
	          </tbody>
	          <?php } ?>
          <?php } ?>         
        </table>
  
      </div>
  
  <div id="tab-refund" class="tab-pane">
  	 <table class="table table-bordered">
  	 	<tr>
            <td>订单号</td>
            <td>
            	{$refund.order_sn}
            </td>
        </tr>
       <!--  <tr>
            <td>申请单号</td>
            <td>
            	{$refund.refund_sn}
            </td>
        </tr> -->
        <tr>
            <td>类型</td>
            <td>
            	{switch name="refund.refund_type"}
					{case value="1"}退款{/case}
					{case value="2"}退款退货{/case}
				{/switch}
            </td>
        </tr>
        <tr>
            <td>备注</td>
            <td>
            	{$refund.refund_title}
            </td>
        </tr>
        <tr>
            <td>原因</td>
            <td>
            	{$refund.reason_info}，{$refund.buyer_message}
            </td>
        </tr>
        <tr>
            <td>订单金额</td>
            <td>
            	{$refund.order_amount}
            </td>
        </tr>
        <tr>
            <td>申请退款金额</td>
            <td>
            	{$refund.refund_amount}
            </td>
        </tr>
        
        <?php if(!empty($refund['pic_info'])){ ?>
        <?php $image=explode('|',$refund['pic_info']); ?>        
        <tr>
        	<td>图片凭证</td>
        	<td> 		
        		<?php foreach($image as $k=>$v){ ?>
        			<a target="_blank" href="/public/uploads/{$v}"><img src="IMG_ROOT{$v|resize=150,150}" /></a>
        		<?php } ?>
        	</td>
        </tr>        
        <?php } ?>       
        
        {if condition="!empty($refund['express_name'])"}
	    <tr>
	        <td>退货物流公司</td>
	        <td>
	        	{$refund.express_name}
	        </td>
	    </tr>
	    <tr>
	        <td>退货物流单号</td>
	        <td>
	        	{$refund.invoice_no}
	        </td>
	    </tr>
    {/if} 
      <tr>
            <td>状态</td>
            <td>
            	{switch name="refund.status"}
					{case value="1"}待处理{/case}
					{case value="2"}已同意{/case}
					{case value="3"} <span style="color:red;">拒绝 ,{$refund.admin_message}</span> {/case}
				{/switch}
            </td>
        </tr>   
  	 </table>
  	 
  	 {if condition="$refund['step'] neq 3 "}
  	  <table class="table table-bordered">
  	  	
  	  	<input name="refund_id" type="hidden" value="{$refund.refund_id}" />
  	  	<input name="order_id" type="hidden" value="{$refund.order_id}" />

  	  	<tr>
  	  		<td>同意申请</td>
  	  		<td>
  	  			<div class="clearfix">					
						<label class="radio-inline"><input type="radio" checked="checked" value="2" name="status">是</label>	
						<label class="radio-inline"><input type="radio" value="3" name="status">否</label>				
				</div>
  	  		</td>
  	  	</tr>
  	  	<tr>
  	  		<td>退款金额</td>
  	  		<td>
  	  			<input type="text" name="amount" value="{$refund.refund_amount}" placeholder="退款金额" class="form-control">
  	  		</td>
  	  	</tr>
  	  	<tr>
  	  		<td>留言</td>
  	  		<td>
  	  			<textarea style="width: 99%" rows="8" cols="40" name="admin_message"></textarea>
  	  		</td>
  	  	</tr>
  	  	<tr>
           	<td colspan="2">
	          <div>
				<button class="btn btn-primary" id="submit">
				确定
				</button>
			  </div>
		  	</td>
        </tr>
  	 </table>
  	 {/if}
  </div>
      
</div>
{/block}
{block name="javascript"}
<script>
$('#submit').click(function(){
	$.ajax({
			url: "{:url('RefundBackend/deal_refund')}",
			type: 'post',
			data: $('input[type=\'text\'],input[type=\'hidden\'],textarea,input[type=\'radio\']:checked'),
			dataType: 'json',	
			beforeSend: function() {
				$('#submit').attr('disabled', true);
				art.dialog({id:'loading',lock: true,title:'加载中'});	
			},	
			complete: function() {
				$('#submit').attr('disabled', false); 
				art.dialog.list['loading'].close();			
			},		
			success: function(json) {				
				if (json.error) {			
					art.dialog({
						content:json.error,
						lock: true,
						ok: function () {}				    
					});																																		
				}else if(json.success){							
					art.dialog({
						content:json.success,
						lock: true,
						ok: function () {
							location = json['url'];
						}				    
					});				
				}  
			}
		});	
});	
</script>
{/block}